<template>
  <div class="lang-set">
    <el-dropdown trigger="click" @command="handleLangCommand">
      <span class="el-dropdown-link" style="cursor: pointer;">
        <svg-icon name="global" class="lang-svg"></svg-icon>
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="zh">中文</el-dropdown-item>
        <el-dropdown-item command="en">English</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
export default {
  name: 'LangSet',
  methods: {
    handleLangCommand (command) {
      this.$i18n.locale = command
      this.$store.dispatch('SetLang', command)
      this.$emit('setLang', command)
    }
  }
}
</script>

<style scoped>
.lang-svg.svg-icon {
  font-size: 18px;
}
</style>
